package engine.parsers.impl;

import engine.content.IContent;
import engine.parsers.IParser;
import engine.services.IContentService;

public final class FSHTMLParser implements IParser{


	// returns the url for the picture after parsing the original url
	public IContent parse(IContent urlContent, IContentService contentService) throws Exception {
		String urlContentStr = urlContent.getContent().toString();
		int startFrom = urlContentStr.indexOf("<div class=\"cartoon\">");
		String findGif = "<img src=\"";
		String gif = urlContent.getContentBase()+"/";
		// this is the actual parsing to get the url for the FS gif
		int i = urlContentStr.indexOf(findGif, startFrom) + findGif.length();
		gif += urlContentStr.substring(i, (urlContentStr.indexOf("\"", i)));

		return contentService.getResponse(gif);
	}
}